import type { ContainerStatus } from "../api/k8s/types";

// Pod 是否处于运行状态
export const isPodRunning = (
  phase: string,
  ableText?: string,
  disableText?: string
): string | boolean => {
  const able = phase === "Running" || phase === "Succeeded";
  if (ableText && able) return ableText;
  if (disableText && !able) return disableText;
  return able;
};

export const getContainerStatus = (container: ContainerStatus): string => {
  if (container.state?.running) {
    return "Running";
  } else if (container.state?.terminated) {
    return "Terminated";
  } else if (container.state?.waiting) {
    return "Waiting";
  } else {
    return "Unknown";
  }
};
